<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use think\Db;
use think\Request;

class IndexController extends HomeBaseController
{
    public function index()
    {
        $nav = getnav();
        $this->assign('nav',$nav);

        $banner = Db::name('slide_item')->where('status',1)->select();
        $banner= $banner->toArray();
        //var_dump($banner);die;
        $this->assign('banner',$banner);

        return $this->fetch(':index');
    }

    public function lianxi(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);
        return $this->fetch(':lianxi');
    }

    public function map(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);
        return $this->fetch(':map');
    }

    public function product(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);
        return $this->fetch(':product');
    }

    public function archives(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);
        return $this->fetch(':archives');
    }

    public function photo(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);

        $album = Db::name('photo_album')->select();

        $this->assign('album',$album);
        return $this->fetch(':photo');
    }

    public function job(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);

        return $this->fetch(':job');
    }
    public function  productlist(){
        //读取数据库对应的内容
        $nav = getnav();
        $this->assign('nav',$nav);
        return $this->fetch(':productlist');
    }

    public function post(Request $request){

        $params = $request->param();

        if($params){

            $data = [
                'txtDescription' => $params['txtDescription'],
                'txtContact' => $params['txtContact'],
                'txtEmail' => $params['txtEmail'],
                'txtMobile' => $params['txtMobile'],
                'txtWeb' => $params['txtWeb']
            ];



            $res = Db::name('info')->insert($data);
            if($res){
                $arr = array(
                    'status'=> 1,
                    'msg'=> '提交成功'
                );
            }else{
                $arr = array(
                    'status'=> 0,
                    'msg'=> '提交失败'
                );
            }
            return json($arr);
        }

    }
}